package com.ruoyi.wash.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.wash.domain.CallRecord;
import com.ruoyi.wash.mapper.CallRecordMapper;
import com.ruoyi.wash.service.ICallRecordService;
import com.ruoyi.wash.vo.CallRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 接口调用记录Service业务层处理
 *
 * @author YanMing.Wang
 * @date 2024-04-30
 */
@Service
public class CallRecordServiceImpl implements ICallRecordService {

    @Autowired
    private CallRecordMapper callRecordMapper;

    /**
     * 查询接口调用记录
     *
     * @param recordId 接口调用记录主键
     * @return 接口调用记录
     */
    @Override
    public CallRecordVO selectCallRecordByRecordId(Long recordId) {
        return callRecordMapper.selectCallRecordByRecordId(recordId);
    }

    /**
     * 查询接口调用记录列表
     *
     * @param callRecord 接口调用记录
     * @return 接口调用记录
     */
    @Override
    public List<CallRecordVO> selectCallRecordList(CallRecord callRecord) {
        callRecord.setStatus("0");
        return callRecordMapper.selectCallRecordList(callRecord);
    }

    /**
     * 新增接口调用记录
     *
     * @param callRecord 接口调用记录
     * @return 结果
     */
    @Override
    public int insertCallRecord(CallRecord callRecord) {
        callRecord.setCreateTime(DateUtils.getNowDate());
        return callRecordMapper.insertCallRecord(callRecord);
    }

    /**
     * 修改接口调用记录
     *
     * @param callRecord 接口调用记录
     * @return 结果
     */
    @Override
    public int updateCallRecord(CallRecord callRecord) {
        callRecord.setUpdateTime(DateUtils.getNowDate());
        return callRecordMapper.updateCallRecord(callRecord);
    }

    /**
     * 批量删除接口调用记录
     *
     * @param recordIds 需要删除的接口调用记录主键
     * @return 结果
     */
    @Override
    public int deleteCallRecordByRecordIds(String recordIds) {
        return callRecordMapper.deleteCallRecordByRecordIds(Convert.toStrArray(recordIds));
    }

    /**
     * 删除接口调用记录信息
     *
     * @param recordId 接口调用记录主键
     * @return 结果
     */
    @Override
    public int deleteCallRecordByRecordId(Long recordId) {
        return callRecordMapper.deleteCallRecordByRecordId(recordId);
    }

    @Override
    public List<CallRecordVO> selectRecordsByLinkId(Long linkId) {
        CallRecord callRecord = new CallRecord();
        callRecord.setLinkId(linkId);
        return callRecordMapper.selectRecordsByLinkId(callRecord);
    }
}
